{extend name="public/layout" /}
{block name="head_css"}
    <link rel="stylesheet" href="/static/home/css/detail.css?v={$version}">
{/block}

{block name="main"}
    <!-- 中间内容区域 -->
    <div class="content-area detail-box">
        <div class="head-line inline-box">
            <div class="left inline-block inline-box">
                <div class="cinfo inline-block">
                    <div class="title">{$vo.name}</div>
                </div>
            </div>
        </div>

        <div class="content-wrapper-box" style="word-wrap : break-word ;">
            {$vo.value}
        </div>

    </div>
    <!-- 中间内容区域 END -->

{/block}
{block name="script"}
    <script>
        var cname = 'chosen';
        var popCname = 'show';
        var masker = $('.transparent-masker');
        var popBox = $('.comment-chosen-pop-box');

        $('.comment-chosen-pop-box .chosen-box .citem').click(function(e) {
            var _this = $(this);
            if(_this.hasClass(cname)) _this.removeClass(cname);
            else _this.addClass(cname);
        });

        $('.picture-gallery .title-line .block .publish-btn').click(function(e) {
            masker.addClass(popCname);
            popBox.addClass(popCname);
        });

        masker.click(function(e) {
            masker.removeClass(popCname);
            popBox.removeClass(popCname);
        });

        var chosenComment = '';
        $('.comment-chosen-pop-box .submit-btn').click(function(e) {
            var citems = $('.comment-chosen-pop-box .chosen-box .citem.chosen');
            if(citems.length < 1) return false;
            var tempArr = [];
            citems.each(function (ind,elm) {
                tempArr.push($(elm).attr('data-id'));
            });
            chosenComment = tempArr.join(',');
            var url = "{:url('add_comment')}";
            var obj = new Object();
            obj.tag_ids = chosenComment;
            obj.id = {$vo.id};
            $.post(url,obj,function(data){
                if(data.code == 1){
                    alert('评论成功！');
                }else if(data.code == -2){
                    alert('请先登录');
                    window.location.href = '{:url('home/login/index')}'
                }else{
                    alert(data.msg);
                }
            });
            masker.removeClass(popCname);
            popBox.removeClass(popCname);
        });

    </script>
{/block}